'use strict'

const { ApiController } = require('jax')

class Controller extends ApiController {
  // 导入xlsx
  async importXlsx() {
    const { ctx } = this
    const { body } = ctx.request

    const results = await this.service.file.importXlsx(body.url)

    ctx.body = {
      code: 0,
      msg: 'success',
      data: results,
    }
  }

  // 导出xlsx
  async exportXlsx() {
    const { ctx } = this
    const { body } = ctx.request

    const result = await this.service.file.exportXlsx(body.data)

    ctx.body = {
      code: 0,
      msg: 'success',
      data: {
        url: result.url,
      },
    }
  }
}

module.exports = Controller
